import pygame, sys, math

from Block import Block

class Gates(Block):
    def __init__(self, pos = (0,0), blocksize = [50,50]):
        self.blocksize = [int(blocksize[0]*1.2),int(blocksize[1]*1.5)]
        self.images = [pygame.transform.scale(pygame.image.load("rsc/effects/gates1.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates2.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates3.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates4.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates4.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates3.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates2.png"), self.blocksize),
                       pygame.transform.scale(pygame.image.load("rsc/effects/gates1.png"), self.blocksize)]
        Block.__init__(self, "rsc/effects/gates1.png", pos, self.blocksize)
        self.frame = 0
        self.maxFrame = len(self.images) - 1
        self.image = self.images[self.frame]
        self.waitCount = 0
        self.waitCountMax = 1
    
    def update(*args):
        self = args[0]
        self.speedx = args[2]
        self.speedy = args[3]
        self.scrollingx = args[4]
        self.scrollingy = args[5]
        self.move()   
        self.animate()
        
    def animate(self):
        if self.waitCount < self.waitCountMax:
            self.waitCount += 1
        else:
            self.waitCount = 0
            if self.frame < self.maxFrame:
                self.frame += 1
            else:
                self.frame = 0
            self.image = self.images[self.frame]